'''
gMenuBar - for the Random Game Generator project            
By Doctus (kirikayuumura.noir@gmail.com)

Menu bar and menu items.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
'''

from PyQt4 import QtGui, QtCore
from gSystem import translate, mainWindow
import sys, os, gStyles

ICON_SELECT = 0
ICON_MOVE = 1
ICON_DRAW = 2
ICON_DELETE = 3

class menuBar(object):
    """An object representing the menu bar."""
    
    def __init__(self):
        
        main = mainWindow
        
        self.menubar = main.menuBar()
        
        # ACTIONS
        
        self.newSessionAct = QtGui.QAction("New Session", main)
        
        self.hostGameAct = QtGui.QAction("&Host Game", main)
        self.hostGameAct.setShortcut("Ctrl+H")

        self.joinGameAct = QtGui.QAction("&Join Game", main)
        self.joinGameAct.setShortcut("Ctrl+J")
        
        self.disconnectAct = QtGui.QAction("&Disconnect", main)
        self.disconnectAct.setShortcut("Ctrl+D")
        
        # MENUS
        
        self.gameMenu = QtGui.QMenu("&Game", main)
        self.gameMenu.addAction(self.newSessionAct)
        
        self.internetMenu = QtGui.QMenu("&Internet", main)
        self.internetMenu.addAction(self.hostGameAct)
        self.internetMenu.addAction(self.joinGameAct)
        self.internetMenu.addAction(self.disconnectAct)
        
        self.stylesMenu = QtGui.QMenu("&Styles", main)
        for style in gStyles.sheets.keys():
            self.stylesMenu.addAction(QtGui.QAction(style, main))
        
        # MENUBAR
        
        self.menubar.addMenu(self.gameMenu)
        self.menubar.addMenu(self.internetMenu)
        self.menubar.addMenu(self.stylesMenu)

        # EVENTS
        
        self.stylesMenu.triggered.connect(self.changeStyle)
        
        mainWindow.setStyleSheet(gStyles.sheets["Celtica"])
    
    def changeStyle(self, act):
        mainWindow.setStyleSheet(gStyles.sheets[unicode(act.text())])
